package com.ljfiction.book.activitys;

import android.os.Bundle;
import android.support.v4.app.Fragment;
import android.support.v4.view.ViewPager;
import android.view.View;
import android.widget.ImageView;

import com.androidkun.xtablayout.XTabLayout;
import com.ljfiction.book.R;
import com.ljfiction.book.adapter.IndentDetailAdapter;
import com.ljfiction.book.fragment.DengjizhiduFragment;
import com.ljfiction.book.fragment.HuoquJifenFragment;

import java.util.ArrayList;

import butterknife.BindView;
import butterknife.ButterKnife;
import butterknife.OnClick;

public class DengjiActivity extends BaseActivity {
    @BindView(R.id.back_dengji)
    ImageView backDengji;
    @BindView(R.id.dengjitable)
    XTabLayout dengjitable;
    @BindView(R.id.dengjiviewpager)
    ViewPager dengjiviewpager;
    private String tabTitles[] = new String[]{"等级列表", "积分规则"};
    private DengjizhiduFragment dengjizhiduFragment;
    private HuoquJifenFragment huoquJifenFragment;
    private ArrayList<Fragment> fragments = new ArrayList<>();
    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_dengji);
        ButterKnife.bind(this);
        intView();
    }

    private void intView() {
        dengjizhiduFragment=new DengjizhiduFragment();
        huoquJifenFragment=new HuoquJifenFragment();
        fragments.add(dengjizhiduFragment);
        fragments.add(huoquJifenFragment);
        IndentDetailAdapter adapter = new IndentDetailAdapter(getSupportFragmentManager(), tabTitles, fragments);
        dengjiviewpager.setAdapter(adapter);
        dengjiviewpager.setOverScrollMode(View.OVER_SCROLL_NEVER);
        dengjitable.setupWithViewPager(dengjiviewpager);
    }

    @OnClick(R.id.back_dengji)
    public void onViewClicked() {
        goBack();
    }
}
